<?php
/**
 * @copyright   Copyright (c) 2017 https://www.sapixx.com All rights reserved.
 * @license     Licensed (http://www.apache.org/licenses/LICENSE-2.0).
 * @author      pillar<ltmn@qq.com>
 * 商家管理
 */
namespace app\ais\model;
use think\Model;
use app\common\facade\Inform;
use app\ais\model\AisStore;

class AisStoreWorker extends Model{
    

    //好店工作ID和用户表绑定关系
    public function user(){
        return $this->hasOne('app\common\model\SystemUser','id','uid');
    }

    //所属好店信息
    public function store(){
        return $this->hasOne('AisStore','id','store_id');
    }
 
     /**
     * 设置好店收银员
     * @param integer $id
     */
    public static function setWorker(int $id){
        $result = self::where(['id' => $id])->field('is_cashier,uid')->find();
        $result->is_cashier = $result->is_cashier ? 0 : 1;
        return $result->save();
    } 
}
